<#include "/common/head.ftl">

<#macro formatOn offering>
	<#if DateUtil.inSameMonth(offering.endDate,toDate?date)>
		;background-color:#B3F5DE
	<#elseif DateUtil.isBetween(offering.startDate, fromDate?date, toDate?date)>
		;background-color:yellow
	</#if>
</#macro>

<html>

<head>
<title>Schedules ${fromDate?date}-${toDate?date}</title>

<style>
	
table.nameTable {
	empty-cells:show;
	border-top: 1px solid black;
	border-right: 1px solid black;
}

table.nameTable tr {
	
}

table.nameTable tr td {
	border-left: 1px solid black;
	border-bottom: 1px solid black;
}

</style>

</head>

<body style="padding:0cm">

<div style="width:29.5cm;text-align:left;margin:0cm;padding:0px">

<h1 style="text-align:center;padding-top:0cm;margin:0cm">SCHEDULES (${fromDate?date}-${toDate?date})</h1>

<table class="nameTable" style="width:28cm;margin-left:0cm;padding:0cm" cellspacing="0" cellpadding=0">
	<tr style="text-align:center;font-weight:bold">
		<td style="background-color:F0FFF0">No.</td>
		<td style="background-color:F0FFF0">Class</td>
		<td style="background-color:F0FFF0">Time</td>
		<td style="background-color:F0FFF0">Start Date</td>
		<td style="background-color:F0FFF0">End Date</td>
		<td style="background-color:F0FFF0">Room</td>
		<td style="background-color:F0FFF0">Number of <br/> students</td>
		<td style="background-color:F0FFF0">Number of <br/> observers</td>
		<#list dates as date>
			<td style="width:1.7cm;background-color:F0FFF0">
				${i18n.getMessage('day.short.' + DateUtil.getDayOfWeek(date))?upper_case} <br/>
				${date?string(i18n.getMessage('format.shortDate'))}
			</td>
		</#list>
		<td style="background-color:F0FFF0">Note</td>
	</tr>
	<#list offerings as offering>
		<tr>
			<td style="width:0.7cm;text-align:center">${offering_index + 1}</td>
			<td style="width:3cm;border-right:0cm<@formatOn offering/>">${offering.name}</td>
			<td style="width:2.5cm;text-align:center<@formatOn offering/>">${(offering.shift.startTime?time)!}-${(offering.shift.endTime?time)!}</td>
			<td style="width:2.5cm;text-align:center<@formatOn offering/>">${((offering.startDate)?date)!}</td>
			<td style="width:2.5cm;text-align:center<@formatOn offering/>">${((offering.endDate)?date)!}</td>
			<td style="width:2cm;text-align:center">${(offering.room.code)!}</td>
			<td style="width:2cm;text-align:center"><#if (offering.numberOfStudents > 0)>${offering.numberOfStudents}<#else>&nbsp;</#if></td>
			<td style="width:2cm;text-align:center"><#if (offering.numberOfObservers > 0)>${offering.numberOfObservers}<#else>&nbsp;</#if></td>
			<#list dates as date>
				<td style="text-align:center">${(offering.dayInstructorMap.get(DateUtil.getDayOfWeek(date)).firstName)!"&nbsp;"}</td>
			</#list>
			<td>&nbsp;</td>
		</tr>
	</#list>
</table>

<p></p>

<table>
	<tr>
		<td style="width:2cm;background-color:yellow">&nbsp;</td>
		<td>New Class</td>
	</tr>
	<tr>
		<td style="background-color:#B3F5DE">&nbsp;</td>
		<td>End Class</td>
	</tr>
</table>

</div>

</body>
</html>